﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


namespace XFGameFramework
{

    public static class RandomExtensions 
    {

        /// <summary>
        /// 随机是否在一定概率的范围内
        /// </summary>
        /// <param name="probability">概率(0-1)</param>
        /// <returns></returns>
        public static bool Random(float probability)
        {
            if (probability >= 1) return true;
            if (probability <= 0) return false;

            int p = Mathf.RoundToInt( probability * 100); 
            return UnityEngine.Random.Range(1, 101) <= p;
        }
    }

}

